
export class Util {
  getAppArgs<T, R>(argName: string): R {
    const app = getApp<{globalData: T}>();
    return  app.globalData[argName] as R;
  }
}



//TODO: cannot be used on iPhone platform
class CaptureScreenImpl {
  private enabled: boolean;

  constructor(enabled: boolean = true){
    this.enabled = enabled
  }

  enable(): boolean {
    if(!this.enabled){ 
      my.setVisualEffectOnCapture({
        visualEffect: 'none',
        success: res => {
          console.log("eable CaptureScreen, ", res);
        },
        fail: error => {
          console.error("enable capture screen failed,", error);
        },
      })
      this.enabled = true;
    }
    return this.enabled;
  }
  disable(): boolean {
    if(this.enabled){
      my.setVisualEffectOnCapture({
        visualEffect: 'hidden',
        success: res => {
          console.log("disable CaptureScreen", res);
        },
        fail: error => {
          console.error("disable CaptureScreen failed,", error);
        },
      });
      this.enabled = false;
    }
    return this.enabled;
  }
}
